package switchviz.gui.component;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;

import switchviz.core.ResourceManager;

public class StatusNotificationLabel extends JPanel
{

	/**
	 * 
	 */
	public static final int WORKING = 0;
	public static final int SUCCESS = 1;
	public static final int FAILURE = 2;
	public static final int WARNING = 3;
	private static final long serialVersionUID = 1982283063022819965L;
	private JLabel _lblmessage = null;
	private JLabel _lblpicture = null;
	
	public StatusNotificationLabel(String message)
	{
		this.setLayout(new BorderLayout());
		this.setMaximumSize(new Dimension(800, 42));
		_lblmessage = new JLabel(message);
		_lblpicture = new JLabel(ResourceManager.getInstance().getImageIconStatusProcess());
		_lblpicture.setPreferredSize(new Dimension(80, 42));
		this.add(_lblmessage, BorderLayout.CENTER);
		this.add(_lblpicture, BorderLayout.WEST);
		
		this.setMessage(message);
	}
	
	public void setMessage(String message)
	{
		_lblmessage.setText(message);
	}
	
	public void setState(int state)
	{
		switch(state)
		{
		case WORKING:
			_lblpicture.setIcon(ResourceManager.getInstance().getImageIconStatusProcess());
			break;
		case SUCCESS:
			_lblpicture.setIcon(ResourceManager.getInstance().getImageIconStatusSuccess());
			break;
		case FAILURE:
			_lblpicture.setIcon(ResourceManager.getInstance().getImageIconStatusError());
			break;
		case WARNING:
			_lblpicture.setIcon(ResourceManager.getInstance().getImageIconStatusWarning());
			break;
		}
	}
	
	public void setNewState(int state, String message)
	{
		this.setMessage(message);
		this.setState(state);
	}
}
